package se.jayway.millionaire.engine;

import se.jayway.millionaire.listener.GameListener;

public class PlayerScore {

	private final GameListener player;
	private int correctAnswersCount;
	private int wrongAnswersCount;
	private int correctAnswersInRowCount;
	private int noAnswersCount;

	public PlayerScore(GameListener player) {
		this.player = player;
	}

	public GameListener getPlayer() {
		return player;
	}
	
	public int countCorrectAnswers() {
		return correctAnswersCount;
	}

	public int countWrongAnswers() {
		return wrongAnswersCount;
	}

	public int countCorrectAnswersInRow() {
		return correctAnswersInRowCount;
	}

	public int countNoAnswers() {
		return noAnswersCount;
	}

	// @OnceAndOnlyOnce
	protected void updateScoreCard(PlayerChoice gameRound, String correctAnswer) {
		String playerAnswer = gameRound.getPlayerAnswer();
		if (playerAnswer == null) {
			noAnswersCount++;
			correctAnswersInRowCount = 0;
		} else if (playerAnswer == correctAnswer) {
			correctAnswersCount++;
			correctAnswersInRowCount++;
		} else {
			wrongAnswersCount++;
			correctAnswersInRowCount = 0;
		}
	}
}
